<?php

namespace App\Http\Controllers\Backend\User;

use Illuminate\Http\Request;
use App\Http\Controllers\Backend\BaseController;
use App\Repository\Repositories\Interfaces\UserRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\ConstDir\ErrorConst;
use Illuminate\Support\Facades\DB;


/**
 * 认证用户管理
 *
 * @package App\Http\Controllers\Backend
 */
class AuthenticationController extends BaseController
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    protected $user_repo;

    public function __construct(UserRepository $user_repo)
    {
        $this->user_repo = $user_repo;
        $this->user_repo->scopeQuery(function ($query){
            return $query->whereIn('identification_type',['1','2','3']);
        });
    }


    public function index()
    {
        $authentication = $this->user_repo->with(['company'=>function($query){
            $query->select(['user_id', 'id','company_name','angent','step']);
        },'company_material'])->paginate($this->perPage,['id','phone','name','created_at','identification_type','personal_enterprise']);

        return $this->success(ErrorConst::SUCCESS_CODE, $authentication,true);

    }



}
